<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

class PhotosController extends Controller
{
    //浏览信息
    public function index()
    {
         $data = \DB::table('pic')->get();
        // dd($data);
        return view('photo.index',['list'=>$data]);
    }
    
    //加载添加表单
    public function create()
    {
       return view("photo.add"); 
    }
    
    //执行信息添加
    public function store(Request $request)
    {
        //获取要添加的数据
        
        $data = ['photo'=>$request->photo,'title'=>$request->title,'addtime'=>$request->addtime];
        //dd($data);
      
        $m = \DB::table("pic")->insertGetId($data);  //返回自增id
         if($m>0){
            return "添加成功; 自增id=".$m;
        }else {
            return "添加失败!";
        }
    }
    
     //单条详细浏览
    public function show($id)
    {
        return "单条详情浏览";
    }
    
    
    //加载编辑表单
    public function edit($id)
    {
        
    }
    
    //执行信息编辑(修改)
    public function update(Request $request,$id)
    {
        
    }
}
